package Java学习;

import java.util.Random;

public class 冒泡排序 {
    public static void main(String[] args) {
        Random rm = new Random();
        int[] arr = new int[100000];
        for (int i = 0; i < arr.length; i++) {
            arr[i] = rm.nextInt();
        }
        long start = System.currentTimeMillis();
        for (int i = 0; i < arr.length-1; i++) {
            for (int i1 = 0; i1 < arr.length-1-i; i1++) {
                if (arr[i1]>arr[i1+1]){
                    int temp = arr[i1];
                    arr[i1] = arr[i1+1];
                    arr[i1+1] = temp;
                }
            }
        }
        long end = System.currentTimeMillis();
        System.out.println(end-start);
//        for (int i = 0; i < arr.length; i++) {
//            System.out.print(arr[i] + " ");
//        }
    }
}
